<template>
	<view class="page mine">
		<uni-card :is-shadow="false" is-full :border="false">
			<view class="content" @click="onModifyInfo()">
				<head-image :name="userInfo.nickName" :url="userInfo.headImage" :size="160"></head-image>
				<view class="info-item">
					<view class="info-primary">
						<text class="info-username">
							{{ userInfo.nickName }}
						</text>
						<text v-show="userInfo.sex == 0" class="iconfont icon-man" color="darkblue"></text>
						<text v-show="userInfo.sex == 1" class="iconfont icon-girl" color="darkred"></text>
					</view>
					<view class="info-text">
						<text class="label-text">
							用户名:
						</text>
						<text class="content-text">
							{{ userInfo.userName }}
						</text>
					</view>
					<view class="info-text">
						<view>
							<!-- <text class="label-text">
								签名:
							</text> -->
							<text class="content-text">
								{{ userInfo.signature }}
							</text>
						</view>
					</view>
				</view>
				<uni-icons class="info-arrow" type="right" color="#b3b3b3" size="16"></uni-icons>
			</view>
		</uni-card>
		<bar-group>
			<arrow-bar title="修改密码" left='icon1' @tap="onModifyPassword()"></arrow-bar>
			<arrow-bar title="注销账号" left='icon2' @tap="$refs.popup.open()"></arrow-bar>
		</bar-group>
		<bar-group>
			<arrow-bar title="用户协议" left='icon3' @tap="onShowProtocol()"></arrow-bar>
			<arrow-bar title="隐私政策" left='icon4' @tap="onShowPrivacy()"></arrow-bar>
		</bar-group>
		<bar-group>
			<btn-bar title="退出登录" type="danger" @click="$refs.popup2.open()"></btn-bar>
		</bar-group>
		<popup-modal ref="popup" title="注销账号" @confirm="confirm()">账号注销后将无法恢复，确认注销吗?</popup-modal>
		<popup-modal ref="popup2" title="确定退出该账号？" @confirm="confirm2()"></popup-modal>
	</view>
</template>

<script>
	import UNI_APP from '@/.env.js';
	export default {
		data() {
			return {
			}
		},
		methods: {
			onModifyInfo() {
				uni.navigateTo({
					url: "/pages/mine/mine-edit"
				})
			},
			onModifyPassword() {
				uni.navigateTo({
					url: "/pages/mine/mine-password"
				})
			},
			onShowProtocol() {
				const linkUrl = encodeURIComponent(UNI_APP.PROTOCOL_URL);
				uni.navigateTo({
					url: '/pages/common/external-link?url=' + linkUrl
				});
			},
			onShowPrivacy() {
				const linkUrl = encodeURIComponent(UNI_APP.PRIVACY_URL);
				uni.navigateTo({
					url: '/pages/common/external-link?url=' + linkUrl
				});
			},
			confirm() {
				this.$http({
					url: '/unregister',
					method: 'DELETE'
				})
			},
			confirm2() {
				getApp().$vm.removeCid();
				getApp().$vm.exit()
			}
		},
		computed: {
			userInfo() {
				return this.userStore.userInfo;
			}
		}
	}
</script>

<style scoped lang="scss">
	.mine {
		.content {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 10rpx;
			padding-right: 30rpx;
			margin-top: -30rpx;


			.info-item {
				display: flex;
				align-items: flex-start;
				flex-direction: column;
				padding-left: 40rpx;
				flex: 1;

				.info-text {
					line-height: 1.5;
				}

				.label-text {
					font-size: $im-font-size-small;
					color: $im-text-color-light;

				}

				.content-text {
					font-size: $im-font-size-small;
					color: $im-text-color-light;
				}

				.info-primary {
					display: flex;
					align-items: center;
					margin-bottom: 10rpx;

					.info-username {
						font-size: 40rpx;
						font-weight: 600;
					}

					.icon-man {
						color: $im-text-color;
						font-size: $im-font-size-large;
						padding-left: 10rpx;
					}

					.icon-girl {
						color: darkred;
					}
				}
			}

			.info-arrow {
				width: 50rpx;
				font-size: 30rpx;
				position: relative;
				left: 20rpx;
			}
		}
	}
</style>